﻿Imports System.Data
Imports System.Configuration
Imports CrystalDecisions.CrystalReports.Engine
Imports System.Configuration.ConfigurationManager
Imports CondorTravel.BC
Imports CondorTravel.BE
Imports CondorTravelUTIL.DL

Public Class RptPaquetes
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try

            Dim objPaqueteBE As PaquetesBE
            Dim strTitulo As String = ""
            objPaqueteBE = New PaquetesBE
            objPaqueteBE.NombrePaquete = "" : objPaqueteBE.FechaInicio = ""
            objPaqueteBE.FechaFinal = "" : objPaqueteBE.Estado = ""
            If Not Request.QueryString("strFIni").Trim Is Nothing And Not Request.QueryString("strFFin").Trim Is Nothing Then
                If Request.QueryString("strFIni").Trim <> "" And Request.QueryString("strFFin").Trim <> "" Then
                    objPaqueteBE.FechaInicio = Request.QueryString("strFIni").Trim
                    objPaqueteBE.FechaFinal = Request.QueryString("strFFin").Trim
                    strTitulo = "Rango de " & objPaqueteBE.FechaInicio & " hasta " & objPaqueteBE.FechaFinal
                End If
            End If
            If Not Request.QueryString("strEsta").Trim Is Nothing Then
                If Request.QueryString("strEsta").Trim <> "" Then
                    objPaqueteBE.Estado = Request.QueryString("strEsta").Trim
                End If
            End If
            If Not Request.QueryString("strPqt").Trim Is Nothing Then
                If Request.QueryString("strPqt").Trim <> "" Then
                    objPaqueteBE.NombrePaquete = Request.QueryString("strPqt").Trim
                End If
            End If

            Dim dtDatos As New DataTable
            Dim objPaqueteBC As PaquetesBC
            objPaqueteBC = New PaquetesBC
            dtDatos = objPaqueteBC.ListaDtsPaquete(objPaqueteBE).Tables(0)
            If dtDatos.Rows.Count <= 0 Then
                lblError.Visible = True
                crvRptPaquetes.Visible = False
            Else
                lblError.Visible = False
                crvRptPaquetes.Visible = True
            End If
            ' Asigno el reporte  
            Dim CrReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            CrReport.Load(Server.MapPath("~/pages/Reportes/crtRptPaquetes.rpt"))
            Dim StrPunRec As TextObject = CrReport.ReportDefinition.ReportObjects.Item("txtUser")
            StrPunRec.Text = CType(Session("usuario"), UsuariosBE).CodUsuario
            Dim StrTit As TextObject = CrReport.ReportDefinition.ReportObjects.Item("txtTitulo")
            StrTit.Text = strTitulo
            CrReport.SetDataSource(dtDatos)
            crvRptPaquetes.ReportSource = CrReport


        Catch ex As ApplicationException
            Response.Write("hola" + ex.Message.ToString())
        End Try
    End Sub

End Class